﻿using System;
using System.Web;

namespace BestEasyCMS.Framework.CookieStorage
{
    /// <summary>
    /// Cookie服务接口
    /// </summary>
    public interface ICookieStorageService
    {
        /// <summary>
        /// 添加Cookie，默认不能跨域访问
        /// </summary>
        /// <param name="cookie">Http Cookie对象</param>
        void AddCookie(HttpCookie cookie);

        /// <summary>
        /// 添加Cookie
        /// </summary>
        /// <param name="cookie">Http Cookie对象</param>
        /// <param name="domain">Cookie的作用域，如需要跨域访问则填写，如：****.一级域名.com</param>
        void AddCookie(HttpCookie cookie, string domain);

        /// <summary>
        /// 添加Cookie
        /// </summary>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        void AddCookie(string key, string value);

        /// <summary>
        /// 添加Cookie
        /// </summary>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        /// <param name="expires">过期时间</param>
        void AddCookie(string key, string value, DateTime expires);

        /// <summary>
        /// 添加为Cookie.Values集合
        /// </summary>
        /// <param name="cookieName">Cookie名称</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        void AddCookie(string cookieName, string key, string value);

        /// <summary>
        /// 添加为Cookie.Values集合
        /// </summary>
        /// <param name="cookieName">Cookie名称</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        /// <param name="expires">过期时间</param>
        void AddCookie(string cookieName, string key, string value, DateTime expires);

        /// <summary>
        /// 获得Http Cookie
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <returns>Cookie</returns>
        HttpCookie GetCookie(string cookieName);

        /// <summary>
        /// 获得Cookie的值
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <param name="key">cookie名称中的Key</param>
        /// <returns>Cookie值</returns>
        string GetCookieValue(string cookieName, string key);

        /// <summary>
        /// 获得Cookie的子键值
        /// </summary>
        /// <param name="cookie">Http Cookie对象</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <returns>Cookie的子键值</returns>
        string GetCookieValue(HttpCookie cookie, string key);

        /// <summary>
        /// 设置Cookie中指定键的值
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        void SetCookie(string cookieName, string key, string value);

        /// <summary>
        /// 设置整个Cookie过期时间
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <param name="expires">过期时间</param>
        void SetCookie(string cookieName, DateTime expires);

        /// <summary>
        /// 设置Cookie
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        /// <param name="value">Cookie子键的值</param>
        /// <param name="expires">过期时间</param>
        void SetCookie(string cookieName, string key, string value, DateTime? expires);

        /// <summary>
        /// 删除指定的Cookie
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        void RemoveCookie(string cookieName);

        /// <summary>
        /// 删除Cookie中指定的键
        /// </summary>
        /// <param name="cookieName">cookie名称</param>
        /// <param name="key">Cookie对象的存在的Key</param>
        void RemoveCookie(string cookieName, string key);
    }
}
